home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / program / qlib205.zip / QLIB.ZIP / TEST / PRINTF.ASM < prev    next >
Assembly Source File  |  1997-02-09  |  2KB  |  78 lines

  1. include qlib.inc
  2. include string.inc
  3. include stdio.inc
  4. include conio.inc
  5. include math.inc
  6. include process.inc
  7.  
  8. .data
  9.   yes db 80 dup (0)
  10.   r1 real8 10.5
  11.   r2 real8 0.5
  12.   r3 real8 0.0
  13.   r4 real8 10.0
  14. .code
  15. main proc
  16.   call clrscr
  17.  
  18.   .if (!_fpu)
  19.     callp printf,"FPU not detected!\n"
  20.     callp exit,0
  21.   .endif
  22.  
  23.   callp printf,"\n\tPrintf tests:\n\n"
  24.   
  25.   callp sprintf,offset yes,"Decimal tests:\n"
  26.   callp print,offset yes
  27.   callp printf,"(d)=%i\n",1234
  28.   callp sprintf,offset yes,"(d)=%u\n",01234
  29.   callp print,offset yes
  30.   callp printf,"(d)=%d\n",-1234
  31.  
  32.   callp printf,"\nFloat tests:\n"
  33.   callp printf,"%%f=%10.2f\n",r1
  34.   callp printf,"%%f=%10.2f\n",r2
  35.   callp printf,"%%f=%10.2f\n",r3
  36.   callp printf,"%%f=%f\n",r3
  37.   callp printf,"%%f=%10.0f\n",r4
  38.   fldl2e  ;st = log2(e)
  39.   fstp r4
  40.   fwait
  41.   callp printf,"%%f=%f\n",r4  ;1.44...
  42.   callp atof,"10.4"
  43.   .if _math_typ==1
  44.     mov dptr[r4+4],eax    ;this is WATCOM style
  45.     mov dptr[r4],edx
  46.   .else
  47.     fstp r4               ;this is Borland style (which I like better now)
  48.     fwait
  49.   .endif
  50.   callp printf,"%%f=%f\n\n",r4
  51.   callp printf,"(x)=%x\n",dptr[r4]           ;see what it looks like
  52.   callp printf,"(x)=%x\n",dptr[r4+4]
  53.  
  54.   callp printf,"\nHex tests:\n"
  55.   callp printf,"(x)=%x\n",12ab56cdh
  56.   callp printf,"(X)=%X\n",12ab56cdh  
  57.  
  58.   callp printf,"Press a key...\n"
  59.   callp getch
  60.  
  61.   callp printf,"\nBinary tests:\n"
  62.   callp printf,"(b)=%05b\n",1
  63.   callp printf,"(b)=%b\n",5678h  
  64.   callp printf,"(b)=%b\n",155  
  65.  
  66.   callp printf,"\nOctal tests:\n"
  67.   callp printf,"(o)=%o\n",5678h  
  68.   callp printf,"(o)=%o\n",155  
  69.  
  70.   callp printf,"\nPrintf %s %s","totally","rulez\n"
  71.   callp sprintf,offset yes,"It %s %s %i%s%i%s%i","Truely","does\n",1,"+",1,"=",2
  72.   callp print,offset yes
  73.   ret
  74. main endp
  75.  
  76. end
  77.  
  78.